package com.hongzhimei.yukicomic.adapter;

import android.media.Image;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.GlideBuilder;
import com.hongzhimei.yukicomic.App;
import com.hongzhimei.yukicomic.R;
import com.hongzhimei.yukicomic.utils.GlideUtils;

import java.util.ArrayList;

/**
 * 作者：Nick CY on 2016/12/21 16:24
 * 邮箱：fsi000044@163.com
 */

public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.Viewholder> {
    public ArrayList<String> datas = null;

    public HomeAdapter(ArrayList<String> datas) {
        this.datas = datas;
    }

    @Override
    public Viewholder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.homepage_item, null);
        return new Viewholder(view);
    }


    @Override
    public void onBindViewHolder(Viewholder holder, int position) {
        holder.home_news_title.setText("猫耳耳机");
        GlideUtils.loadImage(App.getContext(),"http://ww1.sinaimg.cn/large/006eg253jw1fay8b6bbf4j30hs0hsabh.jpg",holder.iv_home);
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public class Viewholder extends RecyclerView.ViewHolder {


        private  TextView home_news_title;
        private  TextView tv_home_desc;
        private  ImageView iv_home;

        public Viewholder(View itemView) {
            super(itemView);
            home_news_title =  (TextView) itemView.findViewById(R.id.home_news_title);
            tv_home_desc = (TextView) itemView.findViewById(R.id.tv_home_desc);
            iv_home = (ImageView) itemView.findViewById(R.id.iv_home);

        }
    }
}
